from django.db import models
from apps.teachers.models import Teacher


# 定义学员模型类
class Student(models.Model):
    SEX_CHOICES = (
        (0, '男'),
        (1, '女'),
        (2, '保密')
    )
    STATE_CHOICES = (
        (0, '学习中'),
        (1, '休学中'),
        (2, '录播学习'),
        (3, '停止服务'),
        (4, '已完结')
    )
    sno = models.CharField(max_length=17, unique=True, verbose_name='学号')
    IDCard = models.CharField(max_length=20, null=True, blank=True, verbose_name='身份证号')
    wechat_nickname = models.CharField(max_length=20, null=True, blank=True, verbose_name='微信昵称')
    name = models.CharField(max_length=20, verbose_name='学员姓名')
    sex = models.SmallIntegerField(choices=SEX_CHOICES, default=2, verbose_name='性别')
    age = models.IntegerField(default=0, verbose_name='年龄')
    telephone = models.CharField(max_length=20, null=True, blank=True, verbose_name='电话')
    state = models.SmallIntegerField(choices=STATE_CHOICES, default=0, verbose_name='学习状态')
    staff = models.ForeignKey(Teacher, on_delete=models.PROTECT, related_name='enter_students', verbose_name='录入人')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
    remark = models.CharField(max_length=50, null=True, blank=True, verbose_name='学员信息备注')

    class Meta:
        # 指明数据库表名
        db_table = 'tb_student'
        # 在admin站点中显示的名称
        verbose_name = '学员表'
        # 显示的复数名称
        verbose_name_plural = verbose_name

    def __str__(self):
        """定义每个数据对象的显示信息"""
        return f"{self.name}({self.sno})"

